<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<input class='check' type="checkbox">
		<input class='check' type="checkbox">
		<input class='check' type="checkbox">
		<input class='check' type="checkbox">
		<input class='check' type="checkbox">
		<input id="checkAll" type="button" value="全选">
		<input id="unCheckAll" type="button" value="全不">
		<input id="reverseCheck" type="button" value="反选">
		
		<script type="text/javascript">
			var checkList = document.getElementsByClassName('check'); //选择框列表
			var checkAll = document.getElementById('checkAll'); //全选
			var unCheckAll = document.getElementById('unCheckAll'); //全不选
			var reverseCheck = document.getElementById('reverseCheck'); //反选




			checkAll.onclick = function() {

				for (var i = 0; i < checkList.length; i++) {
					checkList[i].checked = true;
				}
			}


			unCheckAll.onclick = function() {

				for (var i = 0; i < checkList.length; i++) {
					checkList[i].checked = false;
				}
			}


			reverseCheck.onclick = function() {

				for (var i = 0; i < checkList.length; i++) {
					console.log(checkList[i].checked);
					checkList[i].checked = !checkList[i].checked;
				}
			}
		</script>
		
	</body>
</html>
